package com.ruoyi.daily.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.daily.domain.dto.LossRateDto;
import com.ruoyi.daily.domain.dto.ReturnOfGoodsTrendArrayDto;
import com.ruoyi.daily.domain.dto.ReturnOfGoodsTrendDto;
import com.ruoyi.daily.domain.dto.TimelyCollectionOfYieldDto;
import com.ruoyi.daily.domain.vo.ByDateAndPageVo;
import com.ruoyi.daily.domain.vo.ByDateVo;
import com.ruoyi.daily.domain.vo.DayAndPageVo;
import com.ruoyi.daily.domain.vo.PageVoAndDateOrYearMonth;
import com.ruoyi.daily.service.QualityReportOneService;
import com.ruoyi.daily.service.WorkOrderManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author cmz
 * @Date 2024-05-30 17:59
 */
@RestController
@RequestMapping("/daily/workOrderManagement")
@Api(tags = "经营日报-工单管理")
public class WorkOrderManagementController {
    @Resource
    private WorkOrderManagementService workOrderManagementService;
    @Resource
    private QualityReportOneService qualityReportOneService;

    @ApiOperation("工单管理")
    @GetMapping("/workOrderManagement")
    public R workOrderManagement() {
        return workOrderManagementService.workOrderManagement();
    }
    
    @ApiOperation("遗失率")
    @PostMapping("/lossRate")
    public R<LossRateDto> lossRate(@RequestBody PageVoAndDateOrYearMonth byDateAndPageVo) {
        return workOrderManagementService.lossRate(byDateAndPageVo);
    }

    @ApiOperation("近7天回货趋势")
    @GetMapping("/returnOfGoodsTrend")
    public R<ReturnOfGoodsTrendArrayDto> returnOfGoodsTrend( ) {
        return workOrderManagementService.returnOfGoodsTrend();
    }

    @ApiOperation("获取柱状图折线图堆叠响应数据")
    @GetMapping("/returnBarLineEcharts/{type}")
    public R<Map<String,Object>> returnBarLineEcharts(
            @ApiParam("0:近七天回货趋势/1:近七天发件业务量/2:近七天签收率")
            @PathVariable Integer type) {
        if (type==0) {
            return workOrderManagementService.returnBarLineEcharts();
        }else if (type==1){
            return qualityReportOneService.returnBarLineEcharts();
        }else if (type == 2){
            return qualityReportOneService.signingRateReturnBarLineEcharts();
        }
        return R.fail("暂无数据");
    }
    

    @ApiOperation("今日回货")
    @GetMapping("/todayReturnOfGoods")
    public R todayReturnOfGoods( ) {
        return workOrderManagementService.todayReturnOfGoods();
    }

    @ApiOperation("各频次回货量")
    @GetMapping("/variousReturnOfGoods")
    public R variousReturnOfGoods() {
        return workOrderManagementService.variousReturnOfGoods();
    }
}
